package com.dependency.postprocessors;

import com.dependency.service.Service1;
import com.dependency.service.Service2;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

import java.util.Calendar;

//@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println(beanName +":" + bean);
        if (beanName.equals("service1")) {
            return new Service1();
        }
        return bean;
    }
}
